package org.fangzz.cameramgr.cameramonitor.service.impl;

import org.fangzz.cameramgr.cameramonitor.dto.StoreQueryParameter;
import org.fangzz.cameramgr.cameramonitor.model.Store;
import org.fangzz.cameramgr.cameramonitor.model.dtr.StoreQueryRequest;
import org.fangzz.cameramgr.cameramonitor.repository.StoreRepository;
import org.fangzz.cameramgr.cameramonitor.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;


/**
 * created by XxChen 2018/6/22
 */


@Service
public class StoreServiceImpl implements StoreService {
    @Autowired
    StoreRepository storeRepository;


    @Override
    public Store findById(Integer storeId) {
        return storeRepository.findById(storeId).get();
    }


    @Override
    public Page<Store> findByAreaCode(StoreQueryRequest request) {
        return storeRepository.findByAreaCode(request.getAreaCode(),PageRequest.of(request.getStart(),request.getLimit()));
    }
}
